<%- include('./layouts/admin_head.ejs') %>

  <div class="main">
    <%- include('./layouts/admin_nav.ejs'); %>
    <div class="container-fluid">
      <div class="page-title">
        <h1>用户</h1>
      </div>
      <!-- 有错误信息时展示 -->
      <div class="alert alert-danger hidden text-center">
        <strong>错误！</strong> <span class="danger-info"></span>
      </div>
      <div class="row">
        <div class="col-md-4">
          <form id="form">
            <h2>添加新用户</h2>
            <div class="form-group">
              <label for="email">邮箱</label>
              <input id="email" class="form-control" name="email" type="email" placeholder="邮箱">
            </div>
            <div class="form-group">
              <label for="slug">别名</label>
              <input id="slug" class="form-control" name="slug" type="text" placeholder="slug">
              <p class="help-block">https://zce.me/author/<strong>slug</strong></p>
            </div>
            <div class="form-group">
              <label for="nickname">昵称</label>
              <input id="nickname" class="form-control" name="nickname" type="text" placeholder="昵称">
            </div>
            <div class="form-group">
              <label for="password">密码</label>
              <input id="password" class="form-control" name="password" type="text" placeholder="密码">
            </div>
            <div class="form-group">
              <div class="add-button">
                <input id="btn-add" class="btn btn-primary" type="button" value="添加">
              </div>
              <div class="edit-button hidden">
                <input id="btn-save" class="btn btn-primary" type="button" value="保存">
                <input id="btn-cancel" class="btn btn-primary" type="button" value="取消">
              </div>
            </div>
          </form>
        </div>
        <div class="col-md-8">
          <div class="page-action">
            <!-- show when multiple checked -->
            <a id="del-multiple" class="btn btn-danger btn-sm" href="javascript:;" style="display: none">批量删除</a>
          </div>
          <table class="table table-striped table-bordered table-hover">
            <thead>
               <tr>
                <th class="text-center" width="40"><input type="checkbox"></th>
                <th class="text-center">头像</th>
                <th>邮箱</th>
                <th>别名</th>
                <th>昵称</th>
                <th>状态</th>
                <th class="text-center">操作</th>
              </tr>
            </thead>
            <tbody>
              
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
<script type="text/template" id="tp" >
  {{each $data val}}
  <tr data-userid="{{val.id}}" >
    <td class="text-center"><input type="checkbox"></td>
    <td class="text-center"><img class="avatar" src="{{val.avatar}}"></td>
    <td>{{val.email}}</td>
    <td>{{val.slug}}</td>
    <td>{{val.nickname}}</td>
    <td>
      {{if (val.status == 'unactivated') }}
        <span class="text-primary">未激活</span>
      {{else if (val.status == 'activated') }}
        <span class="text-success">已激活</span> 
      {{else if (val.status == 'forbidden') }}
        <span class="text-danger">已禁止</span>
      {{else if (val.status == 'trashed') }}
        <span class="text-muted">已作废</span>
      {{/if}}
    </td>
    <td class="text-center">
      <a href="javascript:;" class="btn edit btn-default btn-xs">编辑</a>
      <a href="javascript:;" class="btn del btn-danger btn-xs">删除</a>      
    </td>
  </tr>
  {{ /each }}
</script>
<%- include('./layouts/admin_aside.ejs'); %>
<%- include('./layouts/admin_footer.ejs'); %>

<script src="/assets/js/admin_users.js"></script>
